import Vue from 'vue'
import VueRouter from 'vue-router'
// 导入组件
const Login = () => import('../views/login/login.vue')
const Home = () => import('../views/home/home.vue')
const Index = () => import('../views/home/index/index.vue')
const My = () => import('../views/home/my/my.vue')
const mycollect = () => import('../views/home/my/mycollect')
const myhistory = () => import('../views/home/my/myhistory')
const mywork = () => import('../views/home/my/mywork')
const myfans = () => import('../views/home/my/myfans')
const Search = () => import('../views/home/search/search.vue')
const SearchResult = () => import('../views/searchResult/searchResult.vue')
const Detail = () => import('../views/detail/detail.vue')
const Info = () => import('../views/info/info.vue')
const Zhi = () => import('../views/zhi/zhi.vue')
const Welcome = () => import('../views/Wecome')
const video = () => import('../views/home/video')
const setting = () => import('../views/system/setting')
const authentication = () => import('../views/system/authentication')
const suggest = () => import('../views/system/suggest')
const message = () => import('../views/system/message')

Vue.use(VueRouter)

const routes = [
  // 登录路由:登录成功之后，应该跳转到我的页面
  { path: '/login', component: Login },
  // 欢迎页面，与默认同地址
  { path: '/welcome', component: Welcome },
  // 验证登录路由:登录成功之后，返回到上一个页面
  { path: '/checkLogin', component: Login },
  // 注册 home 路由
  {
    path: '/home',
    alias: '/',
    component: Home,
    redirect: '/index',
    children: [
      { path: '/index', component: Index }, // 主页路由
      { path: '/my', component: My }, // 我的路由
      { path: '/search', component: Search }, // 搜索路由
      { path: '/video', component: video } // 搜索路由
    ]
  },
  { path: '/mycollect', component: mycollect },
  { path: '/myhistory', component: myhistory },
  { path: '/mywork', component: mywork },
  { path: '/myfans', component: myfans },
  { path: '/setting', component: setting }, // 系统设置
  { path: '/authentication', component: authentication }, // 实名认证
  { path: '/suggest', component: suggest }, // 反馈建议
  { path: '/message', component: message }, // 反馈建议
  { path: '/searchResult/:key', component: SearchResult },
  // 文章详情
  { path: '/detail/:artid', component: Detail },
  { path: '/info', component: Info },
  // 小智同学
  { path: '/zhi', component: Zhi }
]

const router = new VueRouter({
  routes
})

export default router
